package dk.soegaard.simpleuddibrowser.style;

import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamSource;

public class Styles {

	public Transformer getBusinessDetailStyle() throws TransformerConfigurationException {
		String location = "http://192.168.1.109:8080/simpleuddibrowser/xslt/businessdetail.xsl";
		return getTransformer(location);
	}
	
	public Transformer getServiceDetailStyle() throws TransformerConfigurationException {
		String location = "http://192.168.1.109:8080/simpleuddibrowser/xslt/servicedetail.xsl";
		return getTransformer(location);
	}
	
	public Transformer getBindingDetailStyle() throws TransformerConfigurationException {
		String location = "http://192.168.1.109:8080/simpleuddibrowser/xslt/bindingdetail.xsl";
		return getTransformer(location);
	}
	
	public Transformer getTModelDetailStyle() throws TransformerConfigurationException {
		String location = "http://192.168.1.109:8080/simpleuddibrowser/xslt/tmodeldetail.xsl";
		return getTransformer(location);
	}
	
	private Transformer getTransformer(String location) throws TransformerConfigurationException {
		TransformerFactory tFactory = TransformerFactory.newInstance();
		StreamSource stylesheetSource = new StreamSource(location);
        Transformer transformer = tFactory.newTransformer(stylesheetSource); 
		transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
        transformer.setOutputProperty(OutputKeys.METHOD, "xml");
	    return transformer;
	}
	
}
